package com.foodchain.service;

import com.foodchain.consts.Consts;
import com.foodchain.entity.Banner;
import com.foodchain.repository.BannerRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BannerService {

    @Resource
    private BannerRepository repository;

    @Value("http://192.168.6.29:8083/img/")
    private String imgPath;

    public List<Banner> findAll() {
        List<Banner> all = repository.findAll();
        if(all.size()>0) {
            for (Banner banner : all) {
                banner.setUrl(Consts.FileUrl.file_url+"/"+ banner.getUrl());
            }
        }
        return all;
    }
}
